#include <bits/stdc++.h>
using namespace std;
int main(){
	
	int n,a[4];
	cin>>n;
	while(n!=6174&&n!=0){
	a[0]=n/1000;
	a[1]=n/100%10;
	a[2]=n/10%10;
	a[3]=n%10;
	sort(a,a+4);
	int n1=a[0]*1000+a[1]*100+a[2]*10+a[3];
	int n2=a[3]*1000+a[2]*100+a[1]*10+a[0];
	n=n2-n1;
		cout<<n2<<"-"<<n1<<"="<<n<<endl;
	}
return 0;
}
